package com.mkvld.appietijdenv2;

import com.mkvld.appietijdenv2.activities.ActMainV9;
import com.mkvld.appietijdenv2.adapters.AdapPeriodFrags;
import com.mkvld.appietijdenv2.data.Preferences;
import com.mkvld.appietijdenv2.fragments.FragExtrasKPTV9;
import com.mkvld.appietijdenv2.fragments.FragExtrasV9;
import com.mkvld.appietijdenv2.fragments.FragPayrollKPTV9;
import com.mkvld.appietijdenv2.fragments.FragPayrollV9;
import com.mkvld.appietijdenv2.fragments.PeriodFragV9;

import android.os.Bundle;
import android.support.v4.view.ViewPager;

public class ActMainGB extends ActMainV9 {
	ViewPager mViewPager;
	AdapPeriodFrags adapter;
	PeriodFragV9[] frags;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.pager);
		
		String[] fragTitles = {
				getResources().getString(R.string.as_shifts),
				getResources().getString(R.string.as_payroll),
				getResources().getString(R.string.as_extras)
		};
		
		frags = new PeriodFragV9[3];
		frags[0] = new FragShiftsGB();
		
		if (Preferences.getContract(this) > 48) {
			frags[1] = new FragPayrollV9();
			frags[2] = new FragExtrasV9();
		} else {
			frags[1] = new FragPayrollKPTV9();
			frags[2] = new FragExtrasKPTV9();
		}
			
		adapter = new AdapPeriodFrags(getSupportFragmentManager(), frags, fragTitles);
		
		mViewPager = (ViewPager)findViewById(R.id.pager);
		mViewPager.setAdapter(adapter);
		
		mViewPager.setCurrentItem(getIntent().getIntExtra("frag", 0));
	}

	@Override
	protected boolean shouldInit() {
		return false;
	}

	@Override
	public void update() {
		super.update();
		for (PeriodFragV9 frag : frags)
			frag.update();
	}
	
}
